# encoding: utf-8

import unittest
from a import *

class test(unittest.TestCase):
    def test_a(self):
        player1 = Hero(name = 'player1',hp = 50,mp = 50,attack = 4,defence = 2)
        enemyer1 = Enemy(name = 'enemyer1',hp = 50,mp = 50,attack = 2,defence = 1)
        
        self.assertEqual(player1.pk(enemyer1),43)
        self.assertEqual(player1.pk(enemyer1),36)
        self.assertEqual(player1.pk(enemyer1),29)
        self.assertEqual(player1.pk(enemyer1),22)   
        self.assertEqual(player1.pk(enemyer1),15)
        self.assertEqual(player1.pk(enemyer1),8)
        self.assertEqual(player1.pk(enemyer1),1)
        self.assertEqual(player1.pk(enemyer1),'enemyer1 is over')
     
    def test_b(self):
        player1 = Hero(name = 'player1',hp = 50,mp = 50,attack = 4,defence = 2)
        enemyer1 = Enemy(name = 'enemyer1',hp = 50,mp = 50,attack = 2,defence = 1)
        head1 = EquipHead(name = '角斗士的头',attack = 1,defence = 2)
        head2 = EquipHead(name = '角斗士的头II',attack = 2,defence = 2)
        head3 = EquipHead(name = '角斗士的头III',attack = 3,defence =2)
        
        player1.equip_head(head1)
        print "player1 穿上了 %s" % head1.name
        self.assertEqual(player1.pk(enemyer1),41)
        print "player1 攻击了 enemyer1，enemyer1 剩余 41 点血"
        player1.equip_head(head2)
        print "player1 换上上了 %s" % head2.name
        self.assertEqual(player1.pk(enemyer1),30)
        print "player1 攻击了 enemyer1，enemyer1 剩余 30 点血"
        
        player1.equip_head(head3)
        print "player1 换上了 %s" % head2.name
        self.assertEqual(player1.pk(enemyer1),17)
        print "player1 攻击了 enemyer1，enemyer1 剩余 17 点血"
    
    def test_c(self):
        player1 = Hero(name = 'player1',hp = 50,mp = 50,attack = 4,defence = 2)
        print "创建了 player1,hp = 50,mp = 50,attack = 4,defence = 2"
        
        enemyer1 = Enemy(name = 'enemyer1',hp = 50,mp = 50,attack = 2,defence = 1)
        print "创建了 enemyer1,hp = 50,mp = 50,attack = 2,defence = 1"

        head1 = EquipHead(name = '角斗士的头',attack = 1,defence = 2)
        print "创建了 角斗士的头 ，attack = 1,defence = 2"
        
        head2 = EquipHead(name = '角斗士的头II',attack = 2,defence =2)
        print "创建了 角斗士的头II ，attack = 2,defence = 2"
        
        body1 = EquipBody(name = '角斗士的胸',attack = 1,defence = 2)
        print "创建了 角斗士的胸 ，attack = 1,defence = 2"
        
        body2 = EquipBody(name = '角斗士的胸II',attack = 2,defence = 2)
        print "创建了 角斗士的胸II ，attack = 2,defence = 2"
        
        
        player1.equip_head(head1)
        print "player1 穿上了 %s" % head1.name
        self.assertEqual(player1.pk(enemyer1),41)
        print "player1 攻击了 enemyer1，enemyer1 剩余 41 点血"
        player1.equip_body(body1)
        print "player1 穿上了 %s" % body1.name
        self.assertEqual(player1.pk(enemyer1),30)
        print "player1 攻击了 enemyer1，enemyer1 剩余 30 点血"
        player1.equip_head(head2)
        player1.equip_body(body2)
        print "player1 换上了 %s 和 %s" % (head2.name,body2.name)
        self.assertEqual(player1.pk(enemyer1),15)
        print "player1 攻击了 enemyer1，enemyer1 剩余 15 点血"
        player1.unequip_head()
        print "player1 卸下了 %s" % head2.name
        self.assertEqual(player1.pk(enemyer1),4)
        print "player1 攻击了 enemyer1，enemyer1 剩余 4 点血"
    

    def test_d(self):
        player1 = Hero(name = 'player1',hp = 50,mp = 50,attack = 4,defence = 2)
        enemyer1 = Enemy(name = 'enemyer1',hp = 50,mp = 50,attack = 2,defence = 1)
        head1 = EquipHead(name = '角斗士的头',attack = 1,defence = 2)
        body1 = EquipBody(name = '角斗士的胸',attack = 1,defence = 2)
        hand1 = EquipHand(name = '角斗士的手',attack = 1,defence = 2)
        leg1 = EquipLeg(name = '角斗士的腿',attack = 1,defence = 2)
        foot1 = EquipFoot(name = '角斗士的脚',attack = 1,defence = 2)
        weapon1 = EquipWeapon(name = '角斗士的武器',attack = 4,defence = 2)
        
        player1.equip_head(head1)
        player1.equip_body(body1)
        player1.equip_hand(hand1)
        player1.equip_leg(leg1)
        player1.equip_foot(foot1)
        player1.equip_weapon(weapon1)
        self.assertEqual(player1.pk(enemyer1),25)
        self.assertEqual(head1.name,'角斗士的头')
        
    def test_e(self):
        player1 = Hero(name = 'player1',hp = 50,mp = 50,attack = 4,defence = 2)
        enemyer1 = Enemy(name = 'enemyer1',hp = 50,mp = 50,attack = 2,defence = 1)
        head1 = EquipHead(name = '角斗士的头',attack = 1,defence = 2)
        
        player1.equip(head1)
        self.assertEqual(player1.pk(enemyer1),41) 

        
if __name__ == '__main__':
    unittest.main()
